/*
* FaceCat的Flutter框架
* 上海卷卷猫信息技术有限公司
*/

import 'package:flutter/material.dart';
import 'dart:math';
import 'dart:async';
import 'facecat.dart';

FCPaint gPaint = FCPaint();
List<FCView> findMyCharts = <FCView>[];
List<FCChart> charts = <FCChart>[];
FCGrid gridStocks = FCGrid();
String latestDataStr = "";
bool isMobile = false;

/*
* 获取主绘图单元
*/
FCPaint getMainPaint(){
  if(!gPaint.hasLoadEvent){
    gPaint.addLoadEvent(onLoad);
  }
  return gPaint;
}

/*
* 绘制最新数据
*/
void drawLatestDiv(FCView view, FCPaint paint, FCRect clipRect){
  double avgHeight = 20;
  String drawFont = "Default,14";
  if (isMobile) {
      drawFont = "Default,12";
  }
  double dTop = 30;
  paint.drawLine(view.borderColor, 1, 0, 0, dTop, view.size.cx, dTop);
  List<String> dataStrs = latestDataStr.split(",");
  double lastClose = 0;
  List<double> priceList = <double>[];
  List<double> volList = <double>[];
  List<String> buySellTexts = <String>[];
  if (dataStrs.length > 10) {
    paint.drawText(dataStrs[0], "rgb(175,196,228)", "Default,14", 5, 7);
    paint.drawText(dataStrs[1], "rgb(194,151,18)", "Default,14", 80, 7);
    lastClose = double.parse(dataStrs[8]);
    priceList.add(double.parse(dataStrs[23]));
    priceList.add(double.parse(dataStrs[22]));
    priceList.add(double.parse(dataStrs[21]));
    priceList.add(double.parse(dataStrs[20]));
    priceList.add(double.parse(dataStrs[19]));
    priceList.add(double.parse(dataStrs[9]));
    priceList.add(double.parse(dataStrs[10]));
    priceList.add(double.parse(dataStrs[11]));
    priceList.add(double.parse(dataStrs[12]));
    priceList.add(double.parse(dataStrs[13]));

    volList.add(double.parse(dataStrs[28]));
    volList.add(double.parse(dataStrs[27]));
    volList.add(double.parse(dataStrs[26]));
    volList.add(double.parse(dataStrs[25]));
    volList.add(double.parse(dataStrs[24]));
    volList.add(double.parse(dataStrs[14]));
    volList.add(double.parse(dataStrs[15]));
    volList.add(double.parse(dataStrs[16]));
    volList.add(double.parse(dataStrs[17]));
    volList.add(double.parse(dataStrs[18]));
  }
  buySellTexts.add("卖5");
  buySellTexts.add("卖4");
  buySellTexts.add("卖3");
  buySellTexts.add("卖2");
  buySellTexts.add("卖1");
  buySellTexts.add("买1");
  buySellTexts.add("买2");
  buySellTexts.add("买3");
  buySellTexts.add("买4");
  buySellTexts.add("买5");
  String textColor = "rgb(175,196,228)";
  if (view.getPaint().defaultUIStyle == "light") {
      textColor = "rgb(0,0,0)";
  }
  double maxVol = maxValue(volList);
  for (int i = 0; i < 10; i++) {
    FCSize tSize = paint.textSize(buySellTexts[i], drawFont);
    paint.drawText(buySellTexts[i], textColor, drawFont, 5, dTop + avgHeight / 2 - tSize.cy / 2);
    if (priceList.isNotEmpty) {
        double price = priceList[i];
        String upDownColor = "rgb(255,82,82)";
        String upDownColor2 = "rgba(255,82,82,50)";
        if (price < lastClose) {
            upDownColor = "rgb(46,255,50)";
            upDownColor2 = "rgba(46,255,50,50)";
        } 
        if (isMobile) {
            paint.drawText(priceList[i].toStringAsFixed(2), upDownColor, drawFont, 40, dTop + avgHeight / 2 - tSize.cy / 2);
        } else {
            paint.drawText(priceList[i].toStringAsFixed(2), upDownColor, drawFont, 50, dTop + avgHeight / 2 - tSize.cy / 2);
        }
        if (maxVol > 0) {
            if (isMobile) {
                paint.fillRect(upDownColor2, view.size.cx - volList[i] * 50 / maxVol, dTop + 2, view.size.cx, dTop + avgHeight - 2);
            } else {
                paint.fillRect(upDownColor2, view.size.cx - volList[i] * 80 / maxVol, dTop + 2, view.size.cx, dTop + avgHeight - 2);
            }
        }
        String volText = (volList[i] / 100).toStringAsFixed(0);
        FCSize volTextSize = paint.textSize(volText, drawFont);
        paint.drawText(volText, textColor, drawFont, view.size.cx - volTextSize.cx - 10, dTop + avgHeight / 2 - volTextSize.cy / 2);
    }
    dTop += avgHeight;
  }
  paint.drawLine(view.borderColor, 1, 0, 0, dTop, view.size.cx, dTop);
  paint.drawText("现价", "rgb(175,196,228)", drawFont, 5, dTop + 10);
  paint.drawText("幅度", "rgb(175,196,228)", drawFont, 5, dTop + 35);
  paint.drawText("总额", "rgb(175,196,228)", drawFont, 5, dTop + 60);
  paint.drawText("总量", "rgb(175,196,228)", drawFont, 5, dTop + 85);
  paint.drawText("开盘", "rgb(175,196,228)", drawFont, 110, dTop + 10);
  paint.drawText("振幅", "rgb(175,196,228)", drawFont, 110, dTop + 35);
  paint.drawText("最高", "rgb(175,196,228)", drawFont, 110, dTop + 60);
  paint.drawText("最低", "rgb(175,196,228)", drawFont, 110, dTop + 85);
  if (dataStrs.length > 10) {
    double close = double.parse(dataStrs[2]);
    double high = double.parse(dataStrs[3]);
    double low = double.parse(dataStrs[4]);
    double open = double.parse(dataStrs[5]);
    double volume = double.parse(dataStrs[6]);
    double amount = double.parse(dataStrs[7]);
    double diff = 0;
    if(lastClose > 0){
        diff = 100 * (close - lastClose) / lastClose;
    }

    double diff2 = 0;
    if(lastClose > 0){
        diff2 = 100 * (high - lastClose) / lastClose - 100 * (low - lastClose) / lastClose;
    }
    paint.drawText(close.toStringAsFixed(2), getPriceColor(close, lastClose), drawFont, 40, dTop + 10);
    paint.drawText(diff.toStringAsFixed(2) + "%", getPriceColor(close, lastClose), drawFont, 40, dTop + 35);
    paint.drawText((amount / 10000).toStringAsFixed(0), textColor, drawFont, 40, dTop + 60);
    paint.drawText((volume / 10000).toStringAsFixed(0), textColor, drawFont, 40, dTop + 85);

    paint.drawText(open.toStringAsFixed(2), getPriceColor(open, lastClose), drawFont, 150, dTop + 10);
    paint.drawText(diff2.toStringAsFixed(2) + "%", getPriceColor(close, lastClose), drawFont, 150, dTop + 35);
    paint.drawText(high.toStringAsFixed(2), getPriceColor(high, lastClose), drawFont, 150, dTop + 60);
    paint.drawText(low.toStringAsFixed(2), getPriceColor(low, lastClose), drawFont, 150, dTop + 85);
  }
}

/*
 *创建单元格
 */
FCGridCell createGridCell(FCGrid grid){
	FCGridCell gridCell = FCGridCell();
	if (grid.getPaint().defaultUIStyle == "dark"){
		gridCell.backColor = "none";
		gridCell.borderColor = "none";
		gridCell.textColor = "rgb(175,196,228)";
  }else if(grid.getPaint().defaultUIStyle == "light"){
		gridCell.backColor = "none";
		gridCell.borderColor = "none";
		gridCell.textColor = "rgb(0,0,0)";
  }
	gridCell.font = "Default,13";
	return gridCell;
}

/*
 *获取价格颜色
 */
String getPriceColor(double price, double comparePrice){
  if (price != 0){
    if (price > comparePrice){
      return "rgb(255,82,82)";
    }else if(price < comparePrice){
      return "rgb(46,255,50)";
    }
  }
  return "rgb(190,190,235)";
}

/*
* 根据名称查找视图
* name:名称
* views:视图集合
*/
void findViewsByType(String findType, List<FCView> views, List<FCView> refViews) {
    int size = views.length;
    for (int i = 0; i < size; i++) {
        FCView view = views[i];
        if (view.viewType == findType) {
            refViews.add(view);
        } else {
            if (view.views.isNotEmpty) {
                findViewsByType(findType, view.views, refViews);
            }
        }
    }
}

/*
*黑色风格
*/
void toBlackChart(FCChart chart, int index){
	chart.getPaint().defaultUIStyle = "dark";
	chart.backColor = "rgb(0,0,0)";
	chart.borderColor = "none";
	chart.textColor = "rgb(175,196,228)";
	chart.scaleColor = "rgb(75,75,75)";
	chart.crossTipColor = "rgb(50,50,50)";
	chart.crossLineColor = "rgb(100,100,100)";
	chart.gridColor = "rgb(50,50,50)";
    if(index > 0){
        chart.upColor = "rgb(186,56,18)";
        chart.downColor = "rgb(31,182,177)";
    }else{
        chart.upColor = "rgb(255,82,82)";
        chart.downColor = "rgb(46,255,50)";
    }
  chart.barStyle = "rect2";
  chart.candleStyle = "rect2";
  chart.trendColor = "rgb(255,255,255)";
  chart.hScaleTextColor = "rgb(194,151,18)";
  chart.vScaleTextColor = "rgb(194,151,18)";
}

/*
* 请求历史数据
*/
void queryHistoryData(FCView mychart, FCChart chart, String code){
  String strCycle = mychart.exAttributes["cycle"] as String;
  int intCycle = int.parse(strCycle);
  String url = "http://110.42.188.197:9968/quote?func=getkline&code=" + code +  "&cycle=" + strCycle + "&count=500";
  if(intCycle == 0){
      url = "http://110.42.188.197:9968/quote?func=getkline&code=" + code +  "&cycle=0&count=240";
  }
  String result = "";
  if(intCycle == 0){
    result = "601857.SH 中国石油\r\n日期,时间,开盘价,最高价,最低价,收盘价,成交量,成交额\r\n2024-08-09,0931,8.580000,8.660000,8.560000,8.640000,4227400.000000,36420868.000000\r\n2024-08-09,0932,8.640000,8.670000,8.630000,8.650000,2680700.000000,23181704.000000\r\n2024-08-09,0933,8.640000,8.660000,8.640000,8.660000,2950100.000000,25529900.000000\r\n2024-08-09,0934,8.670000,8.680000,8.660000,8.670000,1241000.000000,10758008.000000\r\n2024-08-09,0935,8.660000,8.660000,8.630000,8.630000,887500.000000,7680170.000000\r\n2024-08-09,0936,8.650000,8.670000,8.640000,8.660000,2737900.000000,23710150.000000\r\n2024-08-09,0937,8.660000,8.660000,8.650000,8.650000,695700.000000,6021513.000000\r\n2024-08-09,0938,8.660000,8.690000,8.650000,8.680000,2916800.000000,25293874.000000\r\n2024-08-09,0939,8.680000,8.680000,8.650000,8.650000,1283100.000000,11115295.000000\r\n2024-08-09,0940,8.640000,8.650000,8.630000,8.650000,688700.000000,5952087.000000\r\n2024-08-09,0941,8.650000,8.650000,8.640000,8.640000,692900.000000,5988518.000000\r\n2024-08-09,0942,8.640000,8.650000,8.640000,8.650000,575200.000000,4971085.000000\r\n2024-08-09,0943,8.650000,8.660000,8.650000,8.660000,1048000.000000,9071571.000000\r\n2024-08-09,0944,8.670000,8.690000,8.660000,8.680000,2154200.000000,18694352.000000\r\n2024-08-09,0945,8.680000,8.680000,8.670000,8.680000,1273200.000000,11052096.000000\r\n2024-08-09,0946,8.680000,8.690000,8.680000,8.680000,772400.000000,6706624.000000\r\n2024-08-09,0947,8.690000,8.700000,8.680000,8.680000,3759800.000000,32684968.000000\r\n2024-08-09,0948,8.680000,8.720000,8.680000,8.700000,3813000.000000,33185340.000000\r\n2024-08-09,0949,8.710000,8.710000,8.700000,8.700000,943300.000000,8208922.000000\r\n2024-08-09,0950,8.700000,8.700000,8.680000,8.690000,1351000.000000,11739704.000000\r\n2024-08-09,0951,8.680000,8.700000,8.680000,8.690000,761000.000000,6613761.000000\r\n2024-08-09,0952,8.680000,8.710000,8.680000,8.700000,1488300.000000,12944661.000000\r\n2024-08-09,0953,8.700000,8.700000,8.690000,8.700000,395400.000000,3438080.000000\r\n2024-08-09,0954,8.700000,8.700000,8.670000,8.680000,1207300.000000,10486797.000000\r\n2024-08-09,0955,8.670000,8.680000,8.670000,8.670000,381500.000000,3309201.000000\r\n2024-08-09,0956,8.670000,8.680000,8.670000,8.680000,672000.000000,5831073.000000\r\n2024-08-09,0957,8.680000,8.690000,8.670000,8.680000,682300.000000,5922031.000000\r\n2024-08-09,0958,8.690000,8.690000,8.680000,8.680000,274100.000000,2380689.000000\r\n2024-08-09,0959,8.690000,8.690000,8.680000,8.680000,720700.000000,6258440.000000\r\n2024-08-09,1000,8.690000,8.720000,8.690000,8.720000,4485800.000000,39032416.000000\r\n2024-08-09,1001,8.720000,8.720000,8.700000,8.720000,1366100.000000,11899445.000000\r\n2024-08-09,1002,8.710000,8.740000,8.710000,8.710000,4425400.000000,38598936.000000\r\n2024-08-09,1003,8.710000,8.710000,8.700000,8.700000,915600.000000,7972173.000000\r\n2024-08-09,1004,8.690000,8.700000,8.680000,8.680000,465000.000000,4041336.000000\r\n2024-08-09,1005,8.690000,8.690000,8.680000,8.690000,282600.000000,2453959.000000\r\n2024-08-09,1006,8.690000,8.700000,8.680000,8.690000,618400.000000,5374127.000000\r\n2024-08-09,1007,8.690000,8.700000,8.690000,8.690000,239300.000000,2081088.000000\r\n2024-08-09,1008,8.690000,8.690000,8.680000,8.680000,532900.000000,4630083.000000\r\n2024-08-09,1009,8.680000,8.690000,8.680000,8.680000,115100.000000,999500.000000\r\n2024-08-09,1010,8.690000,8.690000,8.680000,8.690000,160100.000000,1390697.000000\r\n2024-08-09,1011,8.680000,8.690000,8.680000,8.690000,294000.000000,2554673.000000\r\n2024-08-09,1012,8.690000,8.690000,8.670000,8.670000,652200.000000,5661244.000000\r\n2024-08-09,1013,8.680000,8.700000,8.670000,8.690000,1263900.000000,10981807.000000\r\n2024-08-09,1014,8.700000,8.700000,8.690000,8.690000,128600.000000,1118222.000000\r\n2024-08-09,1015,8.690000,8.710000,8.690000,8.700000,661400.000000,5754626.000000\r\n2024-08-09,1016,8.710000,8.710000,8.700000,8.700000,318000.000000,2768593.000000\r\n2024-08-09,1017,8.710000,8.710000,8.700000,8.710000,354400.000000,3084533.000000\r\n2024-08-09,1018,8.700000,8.710000,8.700000,8.700000,332700.000000,2895008.000000\r\n2024-08-09,1019,8.700000,8.710000,8.690000,8.700000,306100.000000,2663591.000000\r\n2024-08-09,1020,8.700000,8.700000,8.690000,8.700000,133400.000000,1160102.000000\r\n2024-08-09,1021,8.690000,8.700000,8.690000,8.690000,286700.000000,2493834.000000\r\n2024-08-09,1022,8.690000,8.720000,8.690000,8.710000,1612700.000000,14041923.000000\r\n2024-08-09,1023,8.720000,8.720000,8.710000,8.720000,188900.000000,1646771.000000\r\n2024-08-09,1024,8.710000,8.720000,8.710000,8.720000,759100.000000,6619039.000000\r\n2024-08-09,1025,8.720000,8.720000,8.700000,8.700000,457900.000000,3988447.000000\r\n2024-08-09,1026,8.700000,8.720000,8.700000,8.720000,1480000.000000,12901078.000000\r\n2024-08-09,1027,8.730000,8.730000,8.720000,8.720000,952300.000000,8311750.000000\r\n2024-08-09,1028,8.720000,8.740000,8.720000,8.730000,2480400.000000,21660740.000000\r\n2024-08-09,1029,8.730000,8.730000,8.720000,8.720000,303600.000000,2649943.000000\r\n2024-08-09,1030,8.730000,8.730000,8.720000,8.730000,289900.000000,2529252.000000\r\n2024-08-09,1031,8.730000,8.740000,8.720000,8.730000,844000.000000,7368101.000000\r\n2024-08-09,1032,8.740000,8.740000,8.720000,8.730000,300700.000000,2626042.000000\r\n2024-08-09,1033,8.730000,8.730000,8.720000,8.720000,362000.000000,3158288.000000\r\n2024-08-09,1034,8.720000,8.720000,8.710000,8.710000,346200.000000,3018498.000000\r\n2024-08-09,1035,8.710000,8.710000,8.700000,8.700000,332800.000000,2896488.000000\r\n2024-08-09,1036,8.700000,8.710000,8.700000,8.710000,132700.000000,1154841.000000\r\n2024-08-09,1037,8.710000,8.710000,8.700000,8.700000,96800.000000,842732.000000\r\n2024-08-09,1038,8.700000,8.710000,8.700000,8.700000,137600.000000,1197799.000000\r\n2024-08-09,1039,8.700000,8.710000,8.700000,8.710000,379600.000000,3305371.000000\r\n2024-08-09,1040,8.710000,8.720000,8.700000,8.710000,333200.000000,2902311.000000\r\n2024-08-09,1041,8.710000,8.720000,8.710000,8.710000,320500.000000,2793171.000000\r\n2024-08-09,1042,8.710000,8.720000,8.700000,8.700000,287600.000000,2505699.000000\r\n2024-08-09,1043,8.710000,8.710000,8.700000,8.710000,173200.000000,1508467.000000\r\n2024-08-09,1044,8.700000,8.710000,8.700000,8.700000,278800.000000,2426955.000000\r\n2024-08-09,1045,8.700000,8.710000,8.700000,8.710000,246400.000000,2145411.000000\r\n2024-08-09,1046,8.710000,8.710000,8.700000,8.700000,188200.000000,1638898.000000\r\n2024-08-09,1047,8.710000,8.720000,8.700000,8.720000,409700.000000,3568417.000000\r\n2024-08-09,1048,8.710000,8.720000,8.710000,8.720000,252900.000000,2205027.000000\r\n2024-08-09,1049,8.720000,8.720000,8.710000,8.720000,602900.000000,5257096.000000\r\n2024-08-09,1050,8.720000,8.740000,8.720000,8.740000,1240800.000000,10831730.000000\r\n2024-08-09,1051,8.730000,8.740000,8.730000,8.730000,318400.000000,2782270.000000\r\n2024-08-09,1052,8.740000,8.740000,8.730000,8.740000,694500.000000,6068897.000000\r\n2024-08-09,1053,8.740000,8.750000,8.730000,8.740000,2481400.000000,21691032.000000\r\n2024-08-09,1054,8.750000,8.750000,8.740000,8.750000,851400.000000,7449285.000000\r\n2024-08-09,1055,8.750000,8.750000,8.740000,8.740000,428900.000000,3751666.000000\r\n2024-08-09,1056,8.740000,8.780000,8.740000,8.770000,5240600.000000,45902676.000000\r\n2024-08-09,1057,8.770000,8.770000,8.750000,8.760000,1327000.000000,11629089.000000\r\n2024-08-09,1058,8.760000,8.760000,8.750000,8.760000,959700.000000,8405837.000000\r\n2024-08-09,1059,8.760000,8.760000,8.750000,8.750000,380500.000000,3329533.000000\r\n2024-08-09,1100,8.740000,8.750000,8.740000,8.750000,574300.000000,5020197.000000\r\n2024-08-09,1101,8.740000,8.750000,8.740000,8.740000,354700.000000,3101121.000000\r\n2024-08-09,1102,8.740000,8.760000,8.740000,8.750000,706500.000000,6183996.000000\r\n2024-08-09,1103,8.760000,8.770000,8.760000,8.760000,248500.000000,2177694.000000\r\n2024-08-09,1104,8.770000,8.770000,8.760000,8.770000,205800.000000,1804103.000000\r\n2024-08-09,1105,8.760000,8.770000,8.760000,8.760000,229500.000000,2011424.000000\r\n2024-08-09,1106,8.760000,8.780000,8.760000,8.780000,1316300.000000,11543499.000000\r\n2024-08-09,1107,8.780000,8.780000,8.770000,8.780000,252000.000000,2212105.000000\r\n2024-08-09,1108,8.780000,8.780000,8.770000,8.770000,1467800.000000,12880173.000000\r\n2024-08-09,1109,8.770000,8.770000,8.760000,8.770000,651700.000000,5714750.000000\r\n2024-08-09,1110,8.770000,8.770000,8.760000,8.770000,302800.000000,2656183.000000\r\n2024-08-09,1111,8.770000,8.770000,8.760000,8.770000,302800.000000,2655277.000000\r\n2024-08-09,1112,8.770000,8.780000,8.770000,8.780000,151000.000000,1324756.000000\r\n2024-08-09,1113,8.770000,8.780000,8.770000,8.770000,633300.000000,5559516.000000\r\n2024-08-09,1114,8.770000,8.780000,8.770000,8.770000,210800.000000,1849843.000000\r\n2024-08-09,1115,8.770000,8.780000,8.770000,8.780000,193600.000000,1698616.000000\r\n2024-08-09,1116,8.770000,8.780000,8.770000,8.770000,154300.000000,1353568.000000\r\n2024-08-09,1117,8.770000,8.770000,8.760000,8.770000,410700.000000,3601320.000000\r\n2024-08-09,1118,8.770000,8.770000,8.760000,8.760000,497700.000000,4361693.000000\r\n2024-08-09,1119,8.760000,8.770000,8.760000,8.760000,272600.000000,2389730.000000\r\n2024-08-09,1120,8.760000,8.770000,8.760000,8.760000,157700.000000,1382282.000000\r\n2024-08-09,1121,8.760000,8.770000,8.760000,8.760000,134300.000000,1177012.000000\r\n2024-08-09,1122,8.770000,8.770000,8.750000,8.750000,392900.000000,3441718.000000\r\n2024-08-09,1123,8.750000,8.760000,8.750000,8.760000,129800.000000,1136793.000000\r\n2024-08-09,1124,8.760000,8.760000,8.750000,8.760000,305600.000000,2676391.000000\r\n2024-08-09,1125,8.760000,8.770000,8.760000,8.760000,263000.000000,2304475.000000\r\n2024-08-09,1126,8.760000,8.770000,8.760000,8.760000,154900.000000,1357159.000000\r\n2024-08-09,1127,8.760000,8.770000,8.760000,8.760000,307800.000000,2697277.000000\r\n2024-08-09,1128,8.760000,8.760000,8.740000,8.740000,821800.000000,7190100.000000\r\n2024-08-09,1129,8.730000,8.740000,8.730000,8.740000,668000.000000,5837950.000000\r\n2024-08-09,1130,8.740000,8.740000,8.730000,8.740000,535900.000000,4679760.000000\r\n2024-08-09,1301,8.740000,8.760000,8.730000,8.750000,1728700.000000,15114657.000000\r\n2024-08-09,1302,8.760000,8.760000,8.740000,8.740000,478900.000000,4190989.000000\r\n2024-08-09,1303,8.750000,8.750000,8.730000,8.730000,792500.000000,6924140.000000\r\n2024-08-09,1304,8.720000,8.730000,8.710000,8.720000,904500.000000,7890455.000000\r\n2024-08-09,1305,8.720000,8.730000,8.710000,8.720000,454200.000000,3960007.000000\r\n2024-08-09,1306,8.720000,8.730000,8.710000,8.730000,406200.000000,3541161.000000\r\n2024-08-09,1307,8.730000,8.730000,8.710000,8.720000,282600.000000,2464300.000000\r\n2024-08-09,1308,8.720000,8.720000,8.710000,8.710000,216800.000000,1889213.000000\r\n2024-08-09,1309,8.710000,8.720000,8.700000,8.710000,587900.000000,5120833.000000\r\n2024-08-09,1310,8.700000,8.720000,8.700000,8.710000,299000.000000,2604505.000000\r\n2024-08-09,1311,8.710000,8.720000,8.710000,8.720000,149100.000000,1299593.000000\r\n2024-08-09,1312,8.710000,8.720000,8.710000,8.710000,121100.000000,1055294.000000\r\n2024-08-09,1313,8.720000,8.730000,8.710000,8.720000,437600.000000,3815725.000000\r\n2024-08-09,1314,8.730000,8.730000,8.720000,8.730000,581600.000000,5072496.000000\r\n2024-08-09,1315,8.720000,8.730000,8.720000,8.720000,266800.000000,2326979.000000\r\n2024-08-09,1316,8.720000,8.730000,8.720000,8.720000,414900.000000,3618137.000000\r\n2024-08-09,1317,8.720000,8.720000,8.710000,8.710000,142600.000000,1243223.000000\r\n2024-08-09,1318,8.720000,8.720000,8.710000,8.720000,256800.000000,2238822.000000\r\n2024-08-09,1319,8.720000,8.720000,8.710000,8.710000,481600.000000,4199074.000000\r\n2024-08-09,1320,8.720000,8.730000,8.720000,8.730000,233900.000000,2040106.000000\r\n2024-08-09,1321,8.730000,8.740000,8.720000,8.740000,408200.000000,3564634.000000\r\n2024-08-09,1322,8.740000,8.740000,8.730000,8.730000,107200.000000,936386.000000\r\n2024-08-09,1323,8.740000,8.740000,8.730000,8.740000,70300.000000,614179.000000\r\n2024-08-09,1324,8.730000,8.750000,8.730000,8.740000,728200.000000,6363412.000000\r\n2024-08-09,1325,8.750000,8.760000,8.740000,8.760000,493800.000000,4320880.000000\r\n2024-08-09,1326,8.760000,8.760000,8.740000,8.740000,616700.000000,5396133.000000\r\n2024-08-09,1327,8.750000,8.750000,8.740000,8.750000,302000.000000,2640692.000000\r\n2024-08-09,1328,8.750000,8.750000,8.740000,8.750000,101600.000000,888552.000000\r\n2024-08-09,1329,8.740000,8.750000,8.740000,8.740000,411100.000000,3594117.000000\r\n2024-08-09,1330,8.740000,8.750000,8.730000,8.740000,236000.000000,2063079.000000\r\n2024-08-09,1331,8.740000,8.750000,8.740000,8.750000,645500.000000,5647720.000000\r\n2024-08-09,1332,8.750000,8.760000,8.750000,8.760000,287300.000000,2512850.000000\r\n2024-08-09,1333,8.750000,8.760000,8.750000,8.760000,561500.000000,4914112.000000\r\n2024-08-09,1334,8.750000,8.760000,8.750000,8.760000,166300.000000,1455845.000000\r\n2024-08-09,1335,8.760000,8.760000,8.750000,8.750000,196500.000000,1720364.000000\r\n2024-08-09,1336,8.760000,8.760000,8.750000,8.760000,394000.000000,3451201.000000\r\n2024-08-09,1337,8.760000,8.770000,8.760000,8.770000,1486300.000000,13021412.000000\r\n2024-08-09,1338,8.770000,8.770000,8.760000,8.760000,751600.000000,6591048.000000\r\n2024-08-09,1339,8.770000,8.780000,8.770000,8.780000,685000.000000,6008543.000000\r\n2024-08-09,1340,8.780000,8.780000,8.770000,8.770000,486400.000000,4267754.000000\r\n2024-08-09,1341,8.770000,8.780000,8.770000,8.770000,375700.000000,3295236.000000\r\n2024-08-09,1342,8.770000,8.780000,8.760000,8.780000,395300.000000,3467035.000000\r\n2024-08-09,1343,8.780000,8.780000,8.770000,8.770000,260800.000000,2288653.000000\r\n2024-08-09,1344,8.780000,8.780000,8.770000,8.770000,233800.000000,2051829.000000\r\n2024-08-09,1345,8.770000,8.770000,8.760000,8.770000,603900.000000,5296426.000000\r\n2024-08-09,1346,8.770000,8.770000,8.750000,8.750000,1053100.000000,9227358.000000\r\n2024-08-09,1347,8.760000,8.770000,8.750000,8.760000,414300.000000,3629250.000000\r\n2024-08-09,1348,8.760000,8.760000,8.750000,8.750000,69200.000000,605899.000000\r\n2024-08-09,1349,8.750000,8.760000,8.750000,8.750000,108200.000000,947078.000000\r\n2024-08-09,1350,8.760000,8.760000,8.750000,8.750000,266900.000000,2335901.000000\r\n2024-08-09,1351,8.750000,8.750000,8.740000,8.740000,265300.000000,2320272.000000\r\n2024-08-09,1352,8.750000,8.750000,8.740000,8.740000,252500.000000,2208663.000000\r\n2024-08-09,1353,8.750000,8.750000,8.740000,8.750000,243500.000000,2130493.000000\r\n2024-08-09,1354,8.750000,8.750000,8.740000,8.750000,95700.000000,836998.000000\r\n2024-08-09,1355,8.750000,8.750000,8.740000,8.740000,134900.000000,1179299.000000\r\n2024-08-09,1356,8.750000,8.750000,8.740000,8.750000,133700.000000,1169509.000000\r\n2024-08-09,1357,8.750000,8.750000,8.740000,8.750000,148400.000000,1297820.000000\r\n2024-08-09,1358,8.750000,8.750000,8.740000,8.750000,102500.000000,896445.000000\r\n2024-08-09,1359,8.750000,8.750000,8.740000,8.740000,208500.000000,1823012.000000\r\n2024-08-09,1400,8.740000,8.750000,8.740000,8.750000,207100.000000,1810863.000000\r\n2024-08-09,1401,8.750000,8.750000,8.730000,8.740000,345500.000000,3019694.000000\r\n2024-08-09,1402,8.740000,8.740000,8.730000,8.730000,301400.000000,2632038.000000\r\n2024-08-09,1403,8.740000,8.740000,8.730000,8.730000,329000.000000,2872333.000000\r\n2024-08-09,1404,8.740000,8.740000,8.730000,8.730000,90700.000000,792079.000000\r\n2024-08-09,1405,8.740000,8.740000,8.730000,8.730000,741000.000000,6469260.000000\r\n2024-08-09,1406,8.730000,8.740000,8.730000,8.730000,133300.000000,1163810.000000\r\n2024-08-09,1407,8.740000,8.740000,8.730000,8.740000,185000.000000,1615472.000000\r\n2024-08-09,1408,8.740000,8.740000,8.730000,8.740000,704500.000000,6157113.000000\r\n2024-08-09,1409,8.740000,8.740000,8.730000,8.730000,97300.000000,849711.000000\r\n2024-08-09,1410,8.740000,8.740000,8.730000,8.730000,270200.000000,2359620.000000\r\n2024-08-09,1411,8.730000,8.740000,8.730000,8.730000,385500.000000,3365908.000000\r\n2024-08-09,1412,8.730000,8.740000,8.730000,8.730000,237400.000000,2073013.000000\r\n2024-08-09,1413,8.740000,8.740000,8.730000,8.730000,236100.000000,2062144.000000\r\n2024-08-09,1414,8.730000,8.730000,8.720000,8.730000,158500.000000,1383368.000000\r\n2024-08-09,1415,8.730000,8.730000,8.720000,8.720000,187100.000000,1632950.000000\r\n2024-08-09,1416,8.730000,8.730000,8.720000,8.720000,133200.000000,1161922.000000\r\n2024-08-09,1417,8.730000,8.730000,8.720000,8.730000,126800.000000,1106056.000000\r\n2024-08-09,1418,8.720000,8.730000,8.720000,8.730000,253400.000000,2211533.000000\r\n2024-08-09,1419,8.730000,8.730000,8.720000,8.720000,146900.000000,1282093.000000\r\n2024-08-09,1420,8.730000,8.730000,8.720000,8.720000,293500.000000,2560783.000000\r\n2024-08-09,1421,8.720000,8.730000,8.720000,8.720000,1019800.000000,8893854.000000\r\n2024-08-09,1422,8.720000,8.730000,8.720000,8.720000,311500.000000,2717893.000000\r\n2024-08-09,1423,8.720000,8.730000,8.720000,8.730000,461000.000000,4023723.000000\r\n2024-08-09,1424,8.730000,8.730000,8.720000,8.720000,370100.000000,3231390.000000\r\n2024-08-09,1425,8.730000,8.740000,8.730000,8.730000,360400.000000,3147474.000000\r\n2024-08-09,1426,8.730000,8.740000,8.730000,8.740000,289800.000000,2531913.000000\r\n2024-08-09,1427,8.730000,8.740000,8.730000,8.730000,301700.000000,2635449.000000\r\n2024-08-09,1428,8.740000,8.740000,8.730000,8.740000,227700.000000,1989675.000000\r\n2024-08-09,1429,8.740000,8.740000,8.730000,8.730000,397400.000000,3471683.000000\r\n2024-08-09,1430,8.740000,8.740000,8.730000,8.740000,225300.000000,1968701.000000\r\n2024-08-09,1431,8.740000,8.750000,8.730000,8.740000,503400.000000,4400337.000000\r\n2024-08-09,1432,8.740000,8.740000,8.720000,8.730000,718200.000000,6273416.000000\r\n2024-08-09,1433,8.720000,8.740000,8.720000,8.730000,371000.000000,3238843.000000\r\n2024-08-09,1434,8.730000,8.740000,8.730000,8.740000,313600.000000,2739948.000000\r\n2024-08-09,1435,8.740000,8.740000,8.730000,8.740000,432400.000000,3778566.000000\r\n2024-08-09,1436,8.740000,8.750000,8.740000,8.750000,465200.000000,4068043.000000\r\n2024-08-09,1437,8.750000,8.750000,8.740000,8.750000,307600.000000,2690912.000000\r\n2024-08-09,1438,8.750000,8.750000,8.740000,8.750000,438800.000000,3837076.000000\r\n2024-08-09,1439,8.750000,8.750000,8.740000,8.740000,486900.000000,4258161.000000\r\n2024-08-09,1440,8.740000,8.750000,8.730000,8.750000,443800.000000,3881061.000000\r\n2024-08-09,1441,8.750000,8.750000,8.740000,8.740000,336000.000000,2938342.000000\r\n2024-08-09,1442,8.740000,8.750000,8.740000,8.740000,554900.000000,4852607.000000\r\n2024-08-09,1443,8.750000,8.750000,8.740000,8.750000,550100.000000,4812584.000000\r\n2024-08-09,1444,8.750000,8.760000,8.740000,8.760000,882400.000000,7720862.000000\r\n2024-08-09,1445,8.760000,8.760000,8.740000,8.750000,1001500.000000,8766408.000000\r\n2024-08-09,1446,8.740000,8.750000,8.740000,8.750000,643100.000000,5626096.000000\r\n2024-08-09,1447,8.750000,8.750000,8.740000,8.750000,624500.000000,5463841.000000\r\n2024-08-09,1448,8.750000,8.750000,8.740000,8.740000,1117100.000000,9765329.000000\r\n2024-08-09,1449,8.740000,8.740000,8.730000,8.740000,586200.000000,5123572.000000\r\n2024-08-09,1450,8.740000,8.750000,8.730000,8.740000,651100.000000,5692692.000000\r\n2024-08-09,1451,8.740000,8.750000,8.730000,8.740000,1338200.000000,11695770.000000\r\n2024-08-09,1452,8.740000,8.750000,8.730000,8.740000,1346200.000000,11767997.000000\r\n2024-08-09,1453,8.740000,8.740000,8.730000,8.740000,1381700.000000,12073413.000000\r\n2024-08-09,1454,8.740000,8.750000,8.730000,8.750000,2221300.000000,19423372.000000\r\n2024-08-09,1455,8.750000,8.750000,8.740000,8.740000,2144500.000000,18760840.000000\r\n2024-08-09,1456,8.750000,8.750000,8.740000,8.750000,1370900.000000,11988387.000000\r\n2024-08-09,1457,8.750000,8.750000,8.740000,8.740000,722000.000000,6314387.000000\r\n2024-08-09,1458,8.740000,8.740000,8.740000,8.740000,5400.000000,47244.000000\r\n2024-08-09,1459,8.740000,8.740000,8.740000,8.740000,0.000000,0.000000\r\n2024-08-09,1500,8.740000,8.740000,8.740000,8.740000,1669100.000000,14587934.000000";
  }else if(intCycle < 1440){
    result = "601857.SH 中国石油\r\n日期,时间,开盘价,最高价,最低价,收盘价,成交量,成交额\r\n2024-07-12,1011,10.440000,10.450000,10.410000,10.430000,2491400.000000,25990557.000000\r\n2024-07-12,1016,10.420000,10.440000,10.400000,10.420000,2184400.000000,22756616.000000\r\n2024-07-12,1021,10.420000,10.430000,10.410000,10.430000,1781200.000000,18564399.000000\r\n2024-07-12,1026,10.420000,10.420000,10.370000,10.410000,4881100.000000,50719321.000000\r\n2024-07-12,1031,10.410000,10.440000,10.410000,10.420000,2246700.000000,23432452.000000\r\n2024-07-12,1036,10.420000,10.440000,10.410000,10.430000,1977600.000000,20609497.000000\r\n2024-07-12,1041,10.440000,10.440000,10.420000,10.420000,811500.000000,8460727.000000\r\n2024-07-12,1046,10.420000,10.430000,10.390000,10.390000,1288400.000000,13404371.000000\r\n2024-07-12,1051,10.400000,10.400000,10.360000,10.370000,3210000.000000,33299165.000000\r\n2024-07-12,1056,10.370000,10.380000,10.360000,10.380000,1206100.000000,12504743.000000\r\n2024-07-12,1101,10.370000,10.370000,10.340000,10.350000,3455400.000000,35776446.000000\r\n2024-07-12,1106,10.350000,10.360000,10.340000,10.360000,981700.000000,10157352.000000\r\n2024-07-12,1111,10.350000,10.360000,10.340000,10.340000,955100.000000,9885401.000000\r\n2024-07-12,1116,10.340000,10.350000,10.320000,10.340000,2391500.000000,24717204.000000\r\n2024-07-12,1121,10.340000,10.350000,10.320000,10.350000,1385700.000000,14314738.000000\r\n2024-07-12,1126,10.350000,10.360000,10.340000,10.350000,1451100.000000,15015559.000000\r\n2024-07-12,1301,10.350000,10.360000,10.330000,10.350000,2909500.000000,30086553.000000\r\n2024-07-12,1306,10.350000,10.350000,10.320000,10.320000,3030600.000000,31306421.000000\r\n2024-07-12,1311,10.330000,10.350000,10.320000,10.340000,2585800.000000,26718339.000000\r\n2024-07-12,1316,10.340000,10.350000,10.310000,10.320000,2209500.000000,22816946.000000\r\n2024-07-12,1321,10.310000,10.320000,10.300000,10.300000,2750400.000000,28345641.000000\r\n2024-07-12,1326,10.310000,10.310000,10.280000,10.290000,3442500.000000,35445048.000000\r\n2024-07-12,1331,10.290000,10.310000,10.290000,10.310000,2102400.000000,21645175.000000\r\n2024-07-12,1336,10.310000,10.310000,10.300000,10.310000,1076100.000000,11086693.000000\r\n2024-07-12,1341,10.300000,10.310000,10.290000,10.300000,2572000.000000,26489171.000000\r\n2024-07-12,1346,10.300000,10.320000,10.290000,10.310000,2855500.000000,29417667.000000\r\n2024-07-12,1351,10.300000,10.310000,10.270000,10.280000,4401400.000000,45289389.000000\r\n2024-07-12,1356,10.290000,10.320000,10.280000,10.310000,1887100.000000,19432307.000000\r\n2024-07-12,1401,10.310000,10.320000,10.280000,10.290000,2449900.000000,25221243.000000\r\n2024-07-12,1406,10.290000,10.310000,10.280000,10.300000,2133900.000000,21957855.000000\r\n2024-07-12,1411,10.310000,10.320000,10.290000,10.300000,1733900.000000,17872608.000000\r\n2024-07-12,1416,10.310000,10.320000,10.300000,10.300000,1090000.000000,11235831.000000\r\n2024-07-12,1421,10.310000,10.320000,10.300000,10.320000,1793000.000000,18482458.000000\r\n2024-07-12,1426,10.320000,10.330000,10.310000,10.320000,1811700.000000,18695568.000000\r\n2024-07-12,1431,10.320000,10.340000,10.310000,10.340000,1219400.000000,12596261.000000\r\n2024-07-12,1436,10.340000,10.340000,10.330000,10.340000,1676800.000000,17329835.000000\r\n2024-07-12,1441,10.340000,10.340000,10.300000,10.300000,2359900.000000,24349523.000000\r\n2024-07-12,1446,10.300000,10.320000,10.300000,10.320000,2351400.000000,24242644.000000\r\n2024-07-12,1451,10.310000,10.320000,10.290000,10.310000,5917500.000000,60947340.000000\r\n2024-07-12,1456,10.300000,10.330000,10.290000,10.330000,3143200.000000,32427016.000000\r\n2024-07-15,0931,10.240000,10.280000,10.140000,10.270000,14202200.000000,144985993.000000\r\n2024-07-15,0936,10.270000,10.310000,10.250000,10.290000,5943100.000000,61013769.000000\r\n2024-07-15,0941,10.290000,10.330000,10.270000,10.320000,4209200.000000,43356038.000000\r\n2024-07-15,0946,10.320000,10.340000,10.300000,10.330000,3645500.000000,37633877.000000\r\n2024-07-15,0951,10.320000,10.380000,10.320000,10.360000,6598500.000000,68337544.000000\r\n2024-07-15,0956,10.360000,10.390000,10.350000,10.380000,4229900.000000,43862808.000000\r\n2024-07-15,1001,10.380000,10.410000,10.360000,10.390000,4484700.000000,46587013.000000\r\n2024-07-15,1006,10.400000,10.420000,10.390000,10.410000,3501800.000000,36442129.000000\r\n2024-07-15,1011,10.430000,10.440000,10.410000,10.410000,4197400.000000,43769026.000000\r\n2024-07-15,1016,10.420000,10.430000,10.380000,10.410000,3625000.000000,37726241.000000\r\n2024-07-15,1021,10.420000,10.430000,10.410000,10.430000,2586700.000000,26949242.000000\r\n2024-07-15,1026,10.420000,10.420000,10.400000,10.410000,3912100.000000,40722230.000000\r\n2024-07-15,1031,10.410000,10.420000,10.370000,10.400000,2781600.000000,28900793.000000\r\n2024-07-15,1036,10.390000,10.430000,10.390000,10.420000,2096000.000000,21822886.000000\r\n2024-07-15,1041,10.430000,10.450000,10.420000,10.420000,3607500.000000,37655548.000000\r\n2024-07-15,1046,10.420000,10.450000,10.420000,10.440000,2445200.000000,25522526.000000\r\n2024-07-15,1051,10.430000,10.480000,10.420000,10.450000,5348000.000000,55899821.000000\r\n2024-07-15,1056,10.440000,10.470000,10.440000,10.450000,2377100.000000,24849394.000000\r\n2024-07-15,1101,10.440000,10.450000,10.430000,10.430000,1544200.000000,16122084.000000\r\n2024-07-15,1106,10.430000,10.450000,10.410000,10.410000,1810400.000000,18877322.000000\r\n2024-07-15,1111,10.410000,10.430000,10.400000,10.400000,1783300.000000,18565337.000000\r\n2024-07-15,1116,10.400000,10.430000,10.390000,10.420000,1619100.000000,16854911.000000\r\n2024-07-15,1121,10.430000,10.440000,10.400000,10.410000,1806000.000000,18809853.000000\r\n2024-07-15,1126,10.420000,10.430000,10.390000,10.420000,1350500.000000,14057318.000000\r\n2024-07-15,1301,10.410000,10.440000,10.390000,10.400000,2441400.000000,25416993.000000";
  }else{
    result = "601857.SH 中国石油\r\n日期,开盘价,最高价,最低价,收盘价,成交量,成交额\r\n2020-07-01,4.190000,4.260000,4.180000,4.250000,86165989.000000,363009056.000000\r\n2020-07-02,4.240000,4.330000,4.230000,4.320000,153857647.000000,659477248.000000\r\n2020-07-03,4.330000,4.450000,4.320000,4.420000,222616461.000000,977995776.000000\r\n2020-07-06,4.440000,4.740000,4.440000,4.720000,443275190.000000,2033077376.000000\r\n2020-07-07,4.770000,4.880000,4.660000,4.700000,397893345.000000,1886736384.000000\r\n2020-07-08,4.670000,4.690000,4.580000,4.670000,270532624.000000,1255098880.000000\r\n2020-07-09,4.680000,4.770000,4.630000,4.740000,261168874.000000,1224971008.000000\r\n2020-07-10,4.700000,4.700000,4.590000,4.600000,202448610.000000,939764864.000000\r\n2020-07-13,4.590000,4.660000,4.570000,4.630000,173551732.000000,801412928.000000\r\n2020-07-14,4.620000,4.620000,4.520000,4.560000,176757915.000000,808283008.000000\r\n2020-07-15,4.580000,4.600000,4.480000,4.490000,150545694.000000,681615872.000000\r\n2020-07-16,4.500000,4.520000,4.400000,4.410000,174747849.000000,778710528.000000\r\n2020-07-17,4.400000,4.430000,4.360000,4.390000,114824684.000000,504085408.000000\r\n2020-07-20,4.400000,4.500000,4.380000,4.490000,130034110.000000,578626496.000000\r\n2020-07-21,4.500000,4.520000,4.450000,4.470000,84861965.000000,379497824.000000\r\n2020-07-22,4.500000,4.650000,4.500000,4.610000,283144151.000000,1303041536.000000\r\n2020-07-23,4.580000,4.600000,4.480000,4.540000,177301977.000000,803923520.000000\r\n2020-07-24,4.620000,4.660000,4.490000,4.500000,216125883.000000,988549056.000000\r\n2020-07-27,4.510000,4.530000,4.420000,4.460000,104263759.000000,465300416.000000\r\n2020-07-28,4.470000,4.510000,4.460000,4.470000,79414097.000000,356134560.000000\r\n2020-07-29,4.450000,4.510000,4.420000,4.500000,90811197.000000,405241056.000000\r\n2020-07-30,4.500000,4.510000,4.450000,4.460000,69025380.000000,308697728.000000\r\n2020-07-31,4.440000,4.510000,4.420000,4.450000,99610118.000000,443949984.000000\r\n2020-08-03,4.450000,4.500000,4.430000,4.480000,124056138.000000,553528896.000000\r\n2020-08-04,4.490000,4.550000,4.460000,4.530000,138654129.000000,624202112.000000\r\n2020-08-05,4.530000,4.530000,4.460000,4.500000,107714697.000000,484087008.000000\r\n2020-08-06,4.530000,4.550000,4.490000,4.530000,141514626.000000,639520832.000000\r\n2020-08-07,4.500000,4.510000,4.440000,4.450000,115958049.000000,518026048.000000\r\n2020-08-10,4.450000,4.480000,4.430000,4.470000,79108815.000000,352778304.000000\r\n2020-08-11,4.490000,4.500000,4.440000,4.450000,92287648.000000,413343296.000000\r\n2020-08-12,4.430000,4.470000,4.410000,4.460000,98193925.000000,436188480.000000\r\n2020-08-13,4.460000,4.500000,4.450000,4.470000,72893696.000000,326345184.000000\r\n2020-08-14,4.470000,4.490000,4.440000,4.480000,63621909.000000,283906240.000000\r\n2020-08-17,4.470000,4.550000,4.470000,4.540000,158287650.000000,715400896.000000\r\n2020-08-18,4.540000,4.550000,4.510000,4.530000,93325518.000000,422979712.000000\r\n2020-08-19,4.530000,4.560000,4.500000,4.520000,97898016.000000,443528192.000000\r\n2020-08-20,4.520000,4.520000,4.450000,4.460000,101289920.000000,453711200.000000\r\n2020-08-21,4.470000,4.480000,4.450000,4.460000,57202289.000000,255417728.000000\r\n2020-08-24,4.480000,4.480000,4.450000,4.460000,60808981.000000,271358784.000000\r\n2020-08-25,4.470000,4.470000,4.430000,4.450000,55872314.000000,248596400.000000\r\n2020-08-26,4.450000,4.460000,4.420000,4.430000,65748886.000000,291875808.000000\r\n2020-08-27,4.420000,4.440000,4.410000,4.430000,47470328.000000,210154096.000000\r\n2020-08-28,4.410000,4.450000,4.400000,4.450000,79414758.000000,351063296.000000\r\n2020-08-31,4.440000,4.460000,4.420000,4.430000,63957297.000000,284304992.000000\r\n2020-09-01,4.420000,4.430000,4.390000,4.410000,71032894.000000,312822080.000000\r\n2020-09-02,4.400000,4.400000,4.340000,4.350000,107928308.000000,470682944.000000\r\n2020-09-03,4.340000,4.370000,4.310000,4.310000,84640042.000000,366929536.000000\r\n2020-09-04,4.290000,4.310000,4.270000,4.310000,72138413.000000,309760672.000000\r\n2020-09-07,4.300000,4.320000,4.280000,4.280000,62805500.000000,269923872.000000\r\n2020-09-08,4.290000,4.310000,4.280000,4.310000,68232926.000000,293003488.000000\r\n2020-09-09,4.280000,4.300000,4.260000,4.280000,75194851.000000,322182112.000000\r\n2020-09-10,4.300000,4.300000,4.230000,4.240000,80951505.000000,345039488.000000\r\n2020-09-11,4.230000,4.260000,4.210000,4.240000,57173409.000000,241936064.000000\r\n2020-09-14,4.250000,4.270000,4.240000,4.260000,38679581.000000,164565184.000000\r\n2020-09-15,4.260000,4.270000,4.230000,4.240000,43619502.000000,185322832.000000\r\n2020-09-16,4.250000,4.290000,4.240000,4.250000,70086386.000000,298688608.000000\r\n2020-09-17,4.260000,4.280000,4.220000,4.230000,82148861.000000,349003040.000000\r\n2020-09-18,4.250000,4.280000,4.230000,4.270000,90199282.000000,383406752.000000\r\n2020-09-21,4.280000,4.280000,4.250000,4.250000,62860331.000000,268049856.000000\r\n2020-09-22,4.160000,4.180000,4.130000,4.140000,80997216.000000,336639392.000000\r\n2020-09-23,4.140000,4.150000,4.110000,4.110000,51865100.000000,213956112.000000\r\n2020-09-24,4.100000,4.110000,4.070000,4.100000,65893121.000000,269260928.000000\r\n2020-09-25,4.100000,4.110000,4.080000,4.090000,35983562.000000,147172400.000000\r\n2020-09-28,4.090000,4.130000,4.090000,4.100000,43686826.000000,179352720.000000\r\n2020-09-29,4.110000,4.110000,4.090000,4.090000,37578762.000000,154065248.000000\r\n2020-09-30,4.090000,4.120000,4.070000,4.110000,61408409.000000,251664112.000000\r\n2020-10-09,4.120000,4.140000,4.120000,4.130000,54100576.000000,223498384.000000\r\n2020-10-12,4.130000,4.190000,4.120000,4.180000,93048731.000000,386727200.000000\r\n2020-10-13,4.170000,4.170000,4.140000,4.150000,43817109.000000,181802768.000000\r\n2020-10-14,4.140000,4.150000,4.100000,4.110000,65172620.000000,268204512.000000\r\n2020-10-15,4.100000,4.120000,4.090000,4.110000,50961732.000000,209334928.000000\r\n2020-10-16,4.110000,4.130000,4.100000,4.110000,47526356.000000,195560640.000000\r\n2020-10-19,4.110000,4.150000,4.100000,4.110000,74216150.000000,305774816.000000\r\n2020-10-20,4.100000,4.100000,4.080000,4.100000,38608445.000000,157965488.000000\r\n2020-10-21,4.100000,4.110000,4.080000,4.110000,50575344.000000,207199088.000000";
  }
  List<String> strs = result.split("\r\n");
  List<SecurityData> dataList = <SecurityData>[];
  chart.firstOpen = 0;
  for(int i = 2; i < strs.length; i++){
      List<String> subStrs = strs[i].split(",");
      if(subStrs.length >= 7){
          SecurityData data = SecurityData();
          if(intCycle < 1440){
              String strDate = subStrs[0] + " " + subStrs[1].substring(0, 2) + ":" + subStrs[1].substring(2, 4) + ":00";
              data.open = double.parse(subStrs[2]);
              data.high = double.parse(subStrs[3]);
              data.low = double.parse(subStrs[4]);
              data.close = double.parse(subStrs[5]);
              data.volume = double.parse(subStrs[6]);
              data.date = i as double;
              if(intCycle == 0 && (data.volume > 0 || dataList.length == 0)){
                  chart.lastValidIndex = dataList.length;
                  if(chart.firstOpen == 0){
                      chart.firstOpen = data.close;
                  }
              }
          }else{
              String strDate =  subStrs[0];
              data.open = double.parse(subStrs[1]);
              data.high = double.parse(subStrs[2]);
              data.low = double.parse(subStrs[3]);
              data.close = double.parse(subStrs[4]);
              data.volume = double.parse(subStrs[5]);
              data.date = i as double;
          }
          dataList.add(data);
      }
  }
  if(intCycle == 0){
      chart.autoFillHScale = true;
      chart.cycle = "trend";
  }else if(intCycle < 1440){
      chart.cycle = "minute";
  }else{
      chart.cycle = "day";
  }
  chart.datas = dataList;
  int maxVisibleRecord = getChartMaxVisibleCount(chart, chart.hScalePixel, getChartWorkAreaWidth(chart));
  chart.lastVisibleIndex = chart.datas.length - 1;
  if (maxVisibleRecord > chart.datas.length) {
      chart.firstVisibleIndex = 0;
  } else {
      chart.firstVisibleIndex = chart.lastVisibleIndex - maxVisibleRecord + 1;
  }
  resetChartVisibleRecord(chart);
  checkChartLastVisibleIndex(chart);
  calcChartIndicator(chart);
  invalidateView(chart);
}

/*
*请求最新数据
*/
void queryNewData(String code){
  String url = "http://110.42.188.197:9968/quote?func=getnewdata&codes=" + code;
  latestDataStr = "601857.SH,中国石油,8.740000,8.780000,8.560000,8.580000,159988600.000000,1394823876.000000,8.550000,8.740000,8.730000,8.720000,8.710000,8.700000,276000,770100,810300,728000,1186800,8.750000,8.760000,8.770000,8.780000,8.790000,959200,1052800,1005100,1845300,1239000,2024-08-09 15:00:00";
  invalidate(gPaint);
}

/*
* 请求报价数据
*/
void queryPrice(String codes){
  String url = "http://110.42.188.197:9968/quote?func=price&count=500&codes=" + codes;
  String result = "600000.SH,浦发银行,8.530000,8.600000,8.410000,8.410000,39120100.000000,334119265.000000,8.380000,29352177375.000000,250373999999.999970,4.640000,1.160000,0.130000,9.220000,7.540000,2024-08-09 15:00:00\r\n600004.SH,XD白云机,9.380000,9.500000,9.380000,9.500000,8033400.000000,75759537.000000,9.450000,2366718283.000000,22200000000.000000,29.580000,0.860000,0.340000,10.400000,8.510000,2024-08-09 15:00:00\r\n600006.SH,东风股份,6.780000,6.990000,6.780000,6.830000,35222400.000000,241283922.000000,6.810000,2000000000.000000,13560000000.000000,24.190000,0.430000,1.760000,7.490000,6.130000,2024-08-09 15:00:00\r\n600007.SH,中国国贸,21.550000,21.800000,21.270000,21.390000,1336100.000000,28895121.000000,21.370000,1007282534.000000,21707000000.000000,16.120000,0.870000,0.130000,23.510000,19.230000,2024-08-09 15:00:00\r\n600008.SH,首创环保,2.900000,2.920000,2.900000,2.920000,29774500.000000,86571613.000000,2.910000,7340590677.000000,21288000000.000000,14.720000,0.550000,0.410000,3.200000,2.620000,2024-08-09 15:00:00\r\n600009.SH,上海机场,34.000000,34.580000,34.000000,34.460000,4586600.000000,157069239.000000,34.310000,2488481340.000000,65516999999.999992,54.830000,0.630000,0.240000,37.740000,30.880000,2024-08-09 15:00:00\r\n600010.SH,包钢股份,1.440000,1.460000,1.440000,1.460000,57457700.000000,83252242.000000,1.450000,45404942248.000000,45356000000.000000,256.900000,0.420000,0.180000,1.600000,1.310000,2024-08-09 15:00:00\r\n600011.SH,华能国际,7.390000,7.490000,7.390000,7.450000,44366300.000000,329906066.000000,7.430000,15698093359.000000,81273000000.000000,7.780000,0.580000,0.400000,8.170000,6.690000,2024-08-09 15:00:00\r\n600012.SH,皖通高速,14.660000,14.980000,14.620000,14.890000,2827100.000000,41627559.000000,14.800000,1658610000.000000,17088000000.000000,13.220000,0.340000,0.240000,16.280000,13.320000,2024-08-09 15:00:00\r\n600015.SH,华夏银行,6.180000,6.240000,6.150000,6.180000,22860300.000000,141797079.000000,6.170000,15914928468.000000,95093000000.000000,4.170000,0.820000,0.150000,6.790000,5.550000,2024-08-09 15:00:00\r\n600016.SH,民生银行,3.440000,3.470000,3.440000,3.440000,107261000.000000,370375560.000000,3.440000,43782418502.000000,121990000000.000020,2.800000,0.760000,0.300000,3.780000,3.100000,2024-08-09 15:00:00\r\n600017.SH,日照港,2.820000,2.840000,2.810000,2.830000,17684100.000000,49952132.000000,2.830000,3075653888.000000,8673000000.000000,11.760000,0.660000,0.570000,3.110000,2.550000,2024-08-09 15:00:00\r\n600018.SH,上港集团,6.020000,6.080000,6.000000,6.070000,15741500.000000,94885855.000000,6.060000,23284144750.000000,139506000000.000000,9.480000,0.660000,0.070000,6.670000,5.450000,2024-08-09 15:00:00\r\n600019.SH,宝钢股份,6.350000,6.420000,6.350000,6.380000,49714800.000000,317318548.000000,6.380000,21985240734.000000,138798000000.000000,18.120000,0.680000,0.230000,7.020000,5.740000,2024-08-09 15:00:00\r\n600020.SH,中原高速,3.750000,3.790000,3.740000,3.770000,7367200.000000,27735967.000000,3.770000,2247371832.000000,8428000000.000000,7.420000,0.550000,0.330000,4.150000,3.390000,2024-08-09 15:00:00\r\n600021.SH,上海电力,8.910000,9.100000,8.900000,9.060000,19713500.000000,176615040.000000,9.030000,2816743645.000000,23319000000.000000,9.900000,0.950000,0.750000,9.930000,8.130000,2024-08-09 15:00:00";
  result += result;
  result += result;
  result += result;
  List<String> strs = result.split("\r\n");
  for(int i = 0; i < strs.length; i++){
      List<String> subStrs = strs[i].split(",");
      if(subStrs.length >= 15){
          FCGridRow row = FCGridRow();
          gridStocks.rows.add(row);
          FCGridCell cell1 = createGridCell(gridStocks);
          cell1.value = i.toStringAsFixed(0);
          row.cells.add(cell1);

          FCGridCell cell2 = createGridCell(gridStocks);
          cell2.value = subStrs[0];
          cell2.textColor = "rgb(194,151,18)";
          row.cells.add(cell2);

          FCGridCell cell3 = createGridCell(gridStocks);
          cell3.value = subStrs[1];
          row.cells.add(cell3);

          double close = double.parse(subStrs[2]);
          double high = double.parse(subStrs[3]);
          double low =  double.parse(subStrs[4]);
          double lastClose = double.parse(subStrs[8]);
          FCGridCell cell4 = createGridCell(gridStocks);
          cell4.value = close.toStringAsFixed(2);
          cell4.textColor = getPriceColor(close, lastClose);
          row.cells.add(cell4);

          double diff = 0;
          if(lastClose > 0){
              diff = 100 * (close - lastClose) / lastClose;
          }
          FCGridCell cell5 = createGridCell(gridStocks);
          cell5.value = diff.toStringAsFixed(2) + "%";
          cell5.textColor = getPriceColor(diff, 0);
          row.cells.add(cell5);

          FCGridCell cell6 = createGridCell(gridStocks);
          cell6.value = (close - lastClose).toStringAsFixed(2);
          cell6.textColor = getPriceColor(close, lastClose);
          row.cells.add(cell6);

          double volume = double.parse(subStrs[6]);
          double amount = double.parse(subStrs[7]);
          FCGridCell cell7 = createGridCell(gridStocks);
          cell7.value = (volume / 100 / 10000).toStringAsFixed(2) + "万";
          row.cells.add(cell7);

          FCGridCell cell8 = createGridCell(gridStocks);
          cell8.value = (amount / 100000000).toStringAsFixed(2) + "亿";
          row.cells.add(cell8);

          FCGridCell cell9 = createGridCell(gridStocks);
          cell9.value = double.parse(subStrs[12]).toStringAsFixed(2);
          row.cells.add(cell9);

          FCGridCell cell10 = createGridCell(gridStocks);
          cell10.value = double.parse(subStrs[11]).toStringAsFixed(2);
          row.cells.add(cell10);

          double diff2 = 0;
          if(lastClose > 0){
              diff2 = 100 * (high - lastClose) / lastClose - 100 * (low - lastClose) / lastClose;
          }
          FCGridCell cell11 = createGridCell(gridStocks);
          cell11.value = diff2.toStringAsFixed(2) + "%";
          row.cells.add(cell11);

          FCGridCell cell12 = createGridCell(gridStocks);
          cell12.value = double.parse(subStrs[13]).toStringAsFixed(2);
          row.cells.add(cell12);

          double marketValue = double.parse(subStrs[9]) * close;
          FCGridCell cell13 = createGridCell(gridStocks);
          cell13.value = (marketValue / 100000000).toStringAsFixed(2) + "亿";
          row.cells.add(cell13);

          double flowValue = double.parse(subStrs[10]) * close;
          FCGridCell cell14 = createGridCell(gridStocks);
          cell14.value = (flowValue / 100000000).toStringAsFixed(2) + "亿";
          row.cells.add(cell14);

          FCGridCell cell15 = createGridCell(gridStocks);
          cell15.value = "";
          row.cells.add(cell15);

          double upperLimit = double.parse(subStrs[14]);
          double lowerLimit = double.parse(subStrs[15]);
          FCGridCell cell16 = createGridCell(gridStocks);
          cell16.value = upperLimit.toStringAsFixed(2);
          cell16.textColor = getPriceColor(1, 0);
          row.cells.add(cell16);

          FCGridCell cell17 = createGridCell(gridStocks);
          cell17.value = lowerLimit.toStringAsFixed(2);
          cell17.textColor = getPriceColor(0, 1);
          row.cells.add(cell17);

          FCGridCell cell18 = createGridCell(gridStocks);
          cell18.value = "";
          row.cells.add(cell18);

          FCGridCell cell19 = createGridCell(gridStocks);
          cell19.value = "";
          row.cells.add(cell19);

          FCGridCell cell20 = createGridCell(gridStocks);
          cell20.value = "";
          row.cells.add(cell20);

          FCGridCell cell21 = createGridCell(gridStocks);
          cell21.value = "";
          row.cells.add(cell21);

          FCGridCell cell22 = createGridCell(gridStocks);
          cell22.value = "";
          row.cells.add(cell22);
      }
  }
  invalidateView(gridStocks);
}

/*
* 加载回调
*/
void onLoad(FCPaint paint){
  paint.defaultUIStyle = "dark";
  paint.size = FCSize(800, 600);
  paint.addPaintEvent(onPaint);
  String xml = """<?xml version="1.0" encoding="utf-8" ?>
        <html xmlns="facecat">
        <body>
            <div bordercolor="none" name="divInner" dock="fill">
                <div type="tab" dock="fill" selectedindex="0" backcolor="none" bordercolor="none"
                name="tabFunc">
                    <div type="tabpage" text="主界面" name="divMain" backcolor="none">
                    <div type="splitlayout" layoutstyle="lefttoright" bordercolor="none" dock="fill"
                            size="650,510" candragsplitter="true" splitterposition="650,1" name="divCodingRight2">
                            <table name="gridStocks" headerheight="30" dock="fill"
                                gridlinecolor="none" bordercolor="none" showvscrollbar="true" showhscrollbar="true"
                                allowpreviewsevent="true" allowdragscroll="true">
                                <tr>
                                    <th name="colP0" text="序" width="40" allowdrag="true" allowresize="true"/>
                                    <th name="colP1" text="代码" width="70" allowdrag="true" allowresize="true"/>
                                    <th name="colP2" text="名称" width="70" allowdrag="true" allowresize="true" />
                                    <th name="colP3" text="现价" width="60" allowdrag="true" allowresize="true" cellalign="right"/>
                                    <th name="colP4" text="涨幅" width="60" allowdrag="true" allowresize="true" cellalign="right"/>
                                    <th name="colP5" text="涨跌" width="60" allowdrag="true" allowresize="true" cellalign="right"/>
                                    <th name="colP9" text="总量" width="60" allowdrag="true" allowresize="true" cellalign="right"/>
                                    <th name="colP10" text="总额" width="60" allowdrag="true" allowresize="true" cellalign="right"/>
                                    <th name="colP11" text="量比" width="60" allowdrag="true" allowresize="true" cellalign="right"/>
                                    <th name="colP12" text="PE动" width="60" allowdrag="true" allowresize="true" cellalign="right"/>
                                    <th name="colP13" text="振幅" width="60" allowdrag="true" allowresize="true" cellalign="right"/>
                                    <th name="colP14" text="换手率" width="60" allowdrag="true" allowresize="true" cellalign="right"/>
                                    <th name="colP15" text="总市值" width="60" allowdrag="true" allowresize="true" cellalign="right"/>
                                    <th name="colP16" text="流值" width="60" allowdrag="true" allowresize="true" cellalign="right"/>
                                    <th name="colP17" text="行业分类板块" width="80" allowdrag="true" allowresize="true" cellalign="center"/>
                                    <th name="colP18" text="涨停价" width="60" allowdrag="true" allowresize="true" cellalign="right"/>
                                    <th name="colP19" text="跌停价" width="60" allowdrag="true" allowresize="true" cellalign="right"/>
                                    <th name="colP20" text="金比" width="60" allowdrag="true" allowresize="true" cellalign="right"/>
                                    <th name="colP21" text="涨跌比" width="60" allowdrag="true" allowresize="true" cellalign="right"/>
                                    <th name="colP22" text="涨速" width="60" allowdrag="true" allowresize="true" cellalign="right"/>
                                    <th name="colP23" text="净资产收益率" width="100" allowdrag="true" allowresize="true" cellalign="right"/>
                                    <th name="colP24" text="自设指标" width="80" allowdrag="true" allowresize="true" cellalign="right"/>
                                </tr>
                            </table>
                            <div type="splitlayout" layoutstyle="toptobottom" bordercolor="none" dock="fill"
                                size="400,400" candragsplitter="true" splitterposition="380,1">
                                <div type="splitlayout" layoutstyle="righttoleft" bordercolor="none" dock="fill"
                                    size="400,400" candragsplitter="true" splitterposition="200,1">
                                    <div type="custom" cid="latestdiv" name="divLatest" />
                                    <div type="custom" cid="mychart" name="mainChart1" cycle="0" candledivpercent="0.7"
                                            voldivpercent="0.3" backcolor="none" bordercolor="none"/>
                                </div>
                                <div type="splitlayout" layoutstyle="lefttoright" bordercolor="none" dock="fill"
                                    size="400,400" candragsplitter="true" splitmode="percentsize" splitterposition="200,1">
                                    <div type="custom" cid="mychart" name="mainChart2" cycle="5" candledivpercent="0.7"
                                            voldivpercent="0.3" backcolor="none" bordercolor="none"/>
                                    <div type="custom" cid="mychart" name="mainChart3" cycle="1440" candledivpercent="0.7"
                                            voldivpercent="0.3" backcolor="none" bordercolor="none"/>
                                </div>
                            </div>
                        </div>
                        </div>
                        <div type="tabpage" text="多K线" name="divMulti" backcolor="none">
                            <div type="splitlayout" layoutstyle="lefttoright" backcolor="none" bordercolor="none"
                                dock="fill" size="400,400" candragsplitter="true" splitmode="percentsize" splitterposition="133,1">
                                <div type="splitlayout" layoutstyle="toptobottom" backcolor="none" bordercolor="none"
                                    dock="fill" size="400,400" candragsplitter="true" splitmode="percentsize" splitterposition="267,1">
                                    <div type="splitlayout" layoutstyle="toptobottom" backcolor="none" bordercolor="none"
                                        dock="fill" size="400,400" candragsplitter="true" splitmode="percentsize" splitterposition="200,1">
                                        <div type="custom" cid="mychart" name="chart1" cycle="1" nativerefresh="true" candledivpercent="1"
                                            voldivpercent="0" backcolor="none" bordercolor="none"/>
                                        <div type="custom" cid="mychart" name="chart2" cycle="5" nativerefresh="true" candledivpercent="1"
                                            voldivpercent="0" backcolor="none" bordercolor="none"/>
                                    </div>
                                    <div type="custom" cid="mychart" name="chart3" cycle="10" nativerefresh="true" candledivpercent="1"
                                        voldivpercent="0" backcolor="none" bordercolor="none"/>
                                </div>
                                <div type="splitlayout" layoutstyle="lefttoright" backcolor="none" bordercolor="none"
                                    dock="fill" size="400,400" candragsplitter="true" splitmode="percentsize" splitterposition="200,1">
                                    <div type="splitlayout" layoutstyle="toptobottom" backcolor="none" bordercolor="none"
                                        dock="fill" size="400,400" candragsplitter="true" splitmode="percentsize" splitterposition="267,1">
                                        <div type="splitlayout" layoutstyle="toptobottom" backcolor="none" bordercolor="none"
                                            dock="fill" size="400,400" candragsplitter="true" splitmode="percentsize" splitterposition="200,1">
                                            <div type="custom" cid="mychart" name="chart4" cycle="15" nativerefresh="true" candledivpercent="1"
                                                voldivpercent="0" backcolor="none" bordercolor="none"/>
                                            <div type="custom" cid="mychart" name="chart5" cycle="20" nativerefresh="true" candledivpercent="1"
                                                voldivpercent="0" backcolor="none" bordercolor="none"/>
                                        </div>
                                        <div type="custom" cid="mychart" name="chart6" cycle="30" nativerefresh="true" candledivpercent="1"
                                            voldivpercent="0" backcolor="none" bordercolor="none"/>
                                    </div>
                                    <div type="splitlayout" layoutstyle="toptobottom" backcolor="none" bordercolor="none"
                                        dock="fill" size="400,400" candragsplitter="true" splitmode="percentsize" splitterposition="267,1">
                                        <div type="splitlayout" layoutstyle="toptobottom" backcolor="none" bordercolor="none"
                                            dock="fill" size="400,400" candragsplitter="true" splitmode="percentsize" splitterposition="200,1">
                                            <div type="custom" cid="mychart" name="chart7" cycle="1440" nativerefresh="true"
                                                candledivpercent="1" voldivpercent="0" backcolor="none" bordercolor="none"/>
                                            <div type="custom" cid="mychart" name="chart8" cycle="10080" nativerefresh="true"
                                                candledivpercent="1" voldivpercent="0" backcolor="none" bordercolor="none"/>
                                        </div>
                                        <div type="custom" cid="mychart" name="chart9" cycle="43200" nativerefresh="true"
                                            candledivpercent="1" voldivpercent="0" backcolor="none" bordercolor="none"/>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
        </body>
        </html>
  """;
  renderFaceCat(paint, xml);
  gridStocks = findViewByName("gridStocks", paint.views) as FCGrid;
  for (int i = 3; i < gridStocks.columns.length; i++) {
    gridStocks.columns[i].cellAlign = "right";
  }
  gridStocks.selectedRowColor = "rgb(75,75,75)";
  gridStocks.alternateRowColor = "rgb(25,25,25)";
  queryPrice("all");

  String strCode = "600000.SH";
  String strName = "浦发银行";
  findViewsByType("mychart", paint.views, findMyCharts);
  for (int i = 0; i < findMyCharts.length; i++) {
    FCView myChart = findMyCharts[i];
    FCSplitLayoutDiv splitDiv = FCSplitLayoutDiv();
    splitDiv.layoutStyle = "toptobottom";
    splitDiv.size = FCSize(400, 400);
    splitDiv.backColor = "none";
    splitDiv.borderColor = "none";
    splitDiv.dock = "fill";
    addViewToParent(splitDiv, myChart);

    FCLayoutDiv topDiv = FCLayoutDiv();
    topDiv.backColor = "none";
    topDiv.borderColor = "none";
    topDiv.layoutStyle = "lefttoright";
    topDiv.showHScrollBar = false;
    addViewToParent(topDiv, splitDiv);

    FCDiv bottomDiv = new FCDiv();
    bottomDiv.backColor = "none";
    bottomDiv.borderColor = "none";
    addViewToParent(bottomDiv, splitDiv);

    splitDiv.setFirstView(topDiv);
    splitDiv.setSecondView(bottomDiv);

    FCView splitter = FCView();
    splitter.setParent(splitDiv);
    if (gPaint.defaultUIStyle == "dark") {
        splitter.backColor = "rgb(75,75,75)";
    } else if (gPaint.defaultUIStyle == "light") {
        splitter.backColor = "rgb(150,150,150)";
    }
    splitter.borderColor = "none";
    splitter.setPaint(gPaint);
    splitDiv.views.add(splitter);
    splitDiv.setSplitter(splitter);
    splitter.size = FCSize(400, 1);
    splitter.location = FCPoint(0, 30);
    if(i == 0){
        splitter.location = FCPoint(0, 0);
    }

    FCChart chart = FCChart();
    chart.leftVScaleWidth = 70;
    chart.rightVScaleWidth = 70;
    if(i > 0){
        chart.leftVScaleWidth = 0;
    }
    chart.vScaleDistance = 35;
    chart.hScalePixel = 11;
    chart.hScaleHeight = 30;
    chart.candlePaddingTop = 30;
    chart.candlePaddingBottom = 20;
    chart.volPaddingTop = 20;
    chart.volPaddingBottom = 0;
    chart.vScaleDistance = 35;
    chart.dock = "fill";
    chart.font = "Default,12";
    chart.candleDivPercent = double.parse(myChart.exAttributes["candledivpercent"] as String);
    chart.volDivPercent = double.parse(myChart.exAttributes["voldivpercent"] as String);
    chart.indDivPercent = 0;
    if (isMobile) {
        chart.rightVScaleWidth = 0;
        chart.leftVScaleWidth = 60;
    }
    chart.text = strCode + " " + strName;
    String strCycle = myChart.exAttributes["cycle"] as String;
    int intCycle = int.parse(strCycle);
    if(intCycle == 0){
        chart.text += " 分时";
    }else if(intCycle < 1440){
        chart.text += " " + intCycle.toString() + "分钟";
    }else if(intCycle == 1440){
        chart.text += " 日线";
    }else if(intCycle == 10080){
        chart.text += " 周线";
    }else if(intCycle == 43200){
        chart.text += " 月线";
    }
    chart.allowDragChartDiv = true;
    charts.add(chart);
    addViewToParent(chart, bottomDiv);
    toBlackChart(chart, i);
    queryHistoryData(myChart, chart, strCode);

    List<String> cycles = <String>[];
    cycles.add("1");
    cycles.add("5");
    cycles.add("10");
    cycles.add("15");
    cycles.add("20");
    cycles.add("30");
    cycles.add("60");
    cycles.add("90");
    cycles.add("120");
    cycles.add("日");
    cycles.add("周");
    cycles.add("月");
    cycles.add("季");
    cycles.add("半");
    cycles.add("年");
    for(int c = 0; c < cycles.length; c++){
        FCButton cycleButton = FCButton();
        cycleButton.text = cycles[c];
        cycleButton.size = FCSize(27, 30);
        cycleButton.textColor = "rgb(200,200,200)";
        cycleButton.borderColor = "rgb(50,50,50)";
        cycleButton.backColor = "none";
        addViewToParent(cycleButton, topDiv);
    }
  }
  queryNewData(strCode);
  updateViewDefault(paint.views);
  invalidate(paint);
}

void main() {
  runApp(MaterialApp(
    debugShowCheckedModeBanner: false,
    home: FCPage()
  ));
}

/*
* 重绘背景的实现方法
* view:视图
* paint:绘图对象
* clipRect:裁剪区域
*/
void onPaint(FCView view, FCPaint paint, FCRect clipRect) {
  if(view.viewType == "latestdiv"){
      drawLatestDiv(view, paint, clipRect);
  }else{
    onPaintDefault(view, paint, clipRect);
  }
}
